package com.midea.testjuc;

import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;

/**
 * @description：
 * @author: wangwl23
 * @create: 2022-03-23 14:29
 */
public class CountDownLatchDemo {
    public static void main(String[] args) {
        /*HashMap map = new HashMap(6);
        map.put(1, 1);*/
        CountDownLatch countDownLatch = new CountDownLatch(10000);


        HashMap<String, String> map = new HashMap<String, String>();
        for (int i = 0;i < 10000; i++) {
             new Thread(new Runnable() {
                @Override
                public void run() {
                     map.put(UUID.randomUUID().toString(), "");
                    countDownLatch.countDown();

                }
            }).start();
        }
        try {
            countDownLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("----");
        System.out.println(map.size());
    }
}
